package com.asset.salesforce.dao;

import java.util.ArrayList;
import java.util.List;

import com.asset.salesforce.domain.InvoiceService;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

@Repository
public class InvoiceServiceDaoImpl extends BasicDaoImpl<InvoiceService>{
	public List<InvoiceService> getInvoiceServicesByInvoice(Integer id){
		Session session =sessionFactory.getCurrentSession();
		Query query = session.createQuery("select service from InvoiceService service, InvoiceItem itm where itm.invoice.id= :id and itm.invoiceItemParent.id = service.id");
		query.setParameter("id", id);
		List<InvoiceService> invoiceServicesList = new ArrayList<InvoiceService>();
		invoiceServicesList = query.list();
		return invoiceServicesList;
	}
}
